package com.jungle.client;

import com.jungle.bfi.domain.vo.DataDefinitionVo;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import lombok.extern.slf4j.Slf4j;

import java.net.URL;
import java.util.ResourceBundle;

@Slf4j
public class BizDesktopController implements Initializable {
    @FXML
    private VBox voucherTemplate;
    @FXML
    private BizScenarioController bizScenarioController;
    @FXML
    private GridPane bizScenario;
    @FXML
    private TableView<DataDefinitionVo> bizBill;
    @FXML
    private BizBillController bizBillController;
    @FXML
    private VoucherTemplateController voucherTemplateController;


    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        log.info("init BizDesktopController, url:{}", url);
        init();
    }

    private void init(){
        log.info("init BizDesktopController");
        bizBill.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
            log.info("oldValue:{}, newValue:{}", oldValue, newValue);
            if (newValue == null) {
                bizScenario.setVisible(false);
            } else {
                bizScenario.setVisible(true);
                bizScenarioController.refreshComponent(newValue);
            }
        });
    }


    public void refresh() {
    }
}
